package com.kun.utils.EmailUtil;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSenderImpl;

/**
 * @Version:v1.0
 * @Author: 鲁坤
 * @Date: 2021-03-16
 * @ClassName: SendEmail
 * @Description: 发送处理邮件 主要是注册审核通过和被拒绝
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class SendEmail {

    @Autowired
    JavaMailSenderImpl mailSender;
    public static final String EMAILFROM = "13100626808@163.com";//静态变量
    SimpleMailMessage mailMessage;
    //发送邮件
    public void AdmitTheRegister(String username , String email){
        mailMessage = new SimpleMailMessage();
        mailMessage.setSubject(username+"你好呀");

        mailMessage.setText("恭喜"+username+"成为LTable的新用户");

        mailMessage.setTo(email);
        mailMessage.setFrom(EMAILFROM);
        mailSender.send(mailMessage);
    }
    public void RefuseTheRegister(String username , String email){
        mailMessage = new SimpleMailMessage();
        mailMessage.setSubject(username+"你好");

        mailMessage.setText("抱歉，由于您资质不符，该申请已被拒绝");

        mailMessage.setTo(email);
        mailMessage.setFrom(EMAILFROM);
        mailSender.send(mailMessage);
    }
}
